﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init {
    import flash.events.*;
    import Engine.Init.*;
    import Classes.util.*;

    public class ItemImageBundleInit extends InitializationAction {

        public static const INIT_ID:String = "BundleInit";

        private var bundles:Array;
        private var loaded:int;
        private var m_progress:int = 0;

        public function ItemImageBundleInit(){
            super(INIT_ID);
            addDependency(BootstrapInit.INIT_ID);
            _weight = 40;
        }
        override public function get progress():int{
            return (this.m_progress);
        }
        override public function execute():void{
            var _local2:BundleLoader;
            var _local3:XML;
            var _local4:XML;
            var _local5:String;
            this.bundles = new Array();
            this.loaded = 0;
            var _local1:XML = Global.bootstrap.setting;
            if (_local1.bootstrap.length() > 0){
                _local3 = _local1.bootstrap[0];
                for each (_local4 in _local3.bundles.bundle) {
                    _local5 = _local4.attribute("locator").toString();
                    this.bundles.push(new BundleLoader(_local5));
                };
            } else {
                this.bundles.push(new BundleLoader("assets/bundle/static.swf"));
                this.bundles.push(new BundleLoader("assets/bundle/dynamic.swf"));
            };
            for each (_local2 in this.bundles) {
                _local2.load(this.onBundleLoaded);
            };
        }
        private function onBundleLoaded(_arg1:Event):void{
            this.loaded++;
            this.m_progress = int(((_weight * this.loaded) / this.bundles.length));
            if (this.loaded == this.bundles.length){
                dispatchEvent(new Event(Event.COMPLETE));
            };
        }

    }
}//package Init 
